package com.listeningframework.boot.autoconfigure.logging.logback;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import ch.qos.logback.classic.helpers.MDCInsertingServletFilter;

/**
 * 
 * Logback增加SessionId到日志
 *
 * @author listening
 * @version $Id: MDCFilterRegister.java, v 0.1 2015年8月23日 下午12:07:21 listening Exp $
 */
@Configuration
public class LogbackConfiguration {
    /**
     * Order
     */
    public static final int ORDER_FILTER_MDC_INSERTING = -3000;

    @Bean
    public FilterRegistrationBean mDCInsertingServletFilterRegistrationBean() {
        FilterRegistrationBean registrationBean = new FilterRegistrationBean();
        MDCInsertingServletFilter mdcInsertingServletFilter = new MDCInsertingServletFilter();
        registrationBean.setFilter(mdcInsertingServletFilter);
        registrationBean.setOrder(ORDER_FILTER_MDC_INSERTING);
        return registrationBean;
    }
}
